package com.xinmanyue.ximalaya;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.ximalaya.ting.android.opensdk.datatrasfer.CommonRequest;
import com.ximalaya.ting.android.opensdk.datatrasfer.IDataCallBack;
import com.ximalaya.ting.android.opensdk.model.category.Category;
import com.ximalaya.ting.android.opensdk.model.category.CategoryList;
import com.xinmanyue.ximalaya.utils.LogUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MainActivity extends AppCompatActivity {

    private static final Class TAG = MainActivity.class;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Map<String, String> map = new HashMap<>();
        CommonRequest.getCategories(map, new IDataCallBack<CategoryList>() {
            @Override
            public void onSuccess(CategoryList categoryList) {
                List<Category> categories = categoryList.getCategories();
                if (categories != null) {
                    int size = categories.size();
                    LogUtils.d(TAG, "size -- " + size);
                    for (Category category : categories) {
                        LogUtils.d(TAG, "category -- " + category.getCategoryName());
                    }
                }
            }

            @Override
            public void onError(int code, String message) {
                LogUtils.e(TAG, "error code -- " + code + ",message -- " + message);
            }
        });
    }
}
